﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Xys.Remp.Thallo {
    static class MethodParseFactory {
        public static IMethodCacheParse GetMethodParse(Type parseType) {
            if (parseType == null) {
                return DynamicMethodCacheParse.Current;
            }

            try {
                var parse = Activator.CreateInstance(parseType) as IMethodCacheParse;
                if (parse == null)
                    throw new InvalidCastException(string.Format("the type of {0} must implements Xys.Remp.Thallo.IMethodParse interface.", parseType.FullName));
                return parse;
            } catch {
                throw;
            }
        }
    }
}
